import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import cesium from 'vite-plugin-cesium'

export default defineConfig({
  plugins: [vue(), vueJsx(), cesium()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
    },
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  },
  build: {
    chunkSizeWarningLimit: 5000000
  },
  server: {
    port: 8080,
    host: '0.0.0.0',
    proxy: {
      "/snt-api": {
        target: 'http://localhost:7001',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/snt-api/, '')
      },
      "/snt-webSocket":{
        target: 'ws://localhost:7001',
        changeOrigin: true,
        ws: true,
        rewrite: path => path.replace(/^\/snt-webSocket/, '')
      }
    }
  }
})
